<?php namespace Home\Controller;
use Hdphp\Controller\Controller;

class ContentController extends Controller{
    public function index(){
        $aid = Q('get.aid',0,'intval');
        //获取文章数据
        $model = new \Common\Model\Arc;
        $data = $model->join('article_data','aid','=','article_aid')->where("aid={$aid}")->find();
        //给文章添加标签数据
        $arcTagModel = new \Common\Model\ArcTag;
        $data['tag'] = $arcTagModel->join('tag','tag_tid','=','tid')->where("article_aid={$aid}")->get();
        //点击次数加1
        $model->where("aid={$aid}")->increment('click',1);
//        获得相关文章获得文章分类
        $cateModel=new \Common\Model\Cate();
        $cateData=$cateModel->join('article','cid','=','category_cid')->where("aid={$aid}")->pluck('cname');
        //select title from article join category on category_cid=cid where (cname=)
        $arcclear=$model->join('category','category_cid','=','cid')->where("cname='{$cateData}'")->where("is_recycle=0")->limit(4)->get();
//       p($arcclear);exit;
        View::with('arcclear',$arcclear);
        View::with('cateData',$cateData);
        View::with('data',$data);
        View::make();
    }
}